<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
/**
* -------------------------------------------------------------------------
* 发布管理模型类
* -------------------------------------------------------------------------
*/
class Pub_model extends CI_Model{
	/**
	* -------------------------------------------------------------------------
	* 发布管理模型类实例化
	* -------------------------------------------------------------------------
	*/
	public function __construct(){
		$this->load->database();
	}
	
	/**
	* -------------------------------------------------------------------------
	* 发布设置（添加）方法
	* -------------------------------------------------------------------------
	*/
	public function save($openid,$status,$content,$pic){
		$returnval='0';
		
		$this->load->helper('url');
		$this->load->helper('security');
		//$this->load->library('cookie');
		//$this->load->library('string');
		
		$this->db->query('insert into user(openid,status,content,pic,pubtime) values("'.$openid.'","'.$status.'","'.$content.'",'.$pic.',"'.date("Y-m-d H:i:s").'")');
		
		return $returnval;
	}
	
	public function countnum(){	
		return $this->db->query('select count(*) as countnum from user');
	}
	
	public function listcontent($pages,$psize){
		$pp=(INT)$pages;
		$ps=(INT)$psize;
		
		$s=$pp*$ps-$ps;
		$e=$ps;
		
		return $this->db->query('select * from user order by pubtime desc limit '.$s.','.$e);
	}
}

/*End of file publish_model.php*/